package com.manage.platform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manage.platform.entity.AchieveOrganizeEntity;
import com.manage.platform.mapper.AchieveOrganizeMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * YWD
 * 2025/11/19
 */
@AllArgsConstructor
@Service
public class AchieveOrganizeServiceImpl extends ServiceImpl<AchieveOrganizeMapper, AchieveOrganizeEntity> {

    public Boolean saveList(Long achieveId, List<Long> organizeList) {
        List<AchieveOrganizeEntity> list = organizeList.stream().map(it -> {
            AchieveOrganizeEntity entity = new AchieveOrganizeEntity();
            entity.setAchieveId(achieveId);
            entity.setOrganizeId(it);
            return entity;
        }).toList();
        return this.saveBatch(list);
    }

    public Boolean removeByAchieveId(Long id) {
        LambdaQueryWrapper<AchieveOrganizeEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AchieveOrganizeEntity::getAchieveId, id);
        return this.remove(queryWrapper);
    }
}
